
using System;
using System.Globalization;
using System.IO;

using CStock;
using CUtil;

using System.Diagnostics;

namespace CStock
{
	/// <summary>
	/// Summary description for Quote.
	/// </summary>
	public class QuoteBase: IQuoteBase
	{
	
        #region fields

	
		protected double cLOSEc ;
	    protected DateTime date ;
        protected DateTime time_OfDay;


		#endregion

		#region Contructors
		private void initQuote()
		{
			this.date = new DateTime(0);
            this.time_OfDay = new DateTime(0);
			this.cLOSEc = 0.0f;
			
		}
		public QuoteBase()
		{
			initQuote();
		}
        public QuoteBase(IQuoteBase quClone)
            
        {
            this.date = quClone.DATE;
            this.time_OfDay = quClone.TIME_OfDay;
            this.cLOSEc = quClone.CLOSEc;
            
        }
        public override string ToString() 
        {
            return this.date.ToShortDateString() + "; " + this.cLOSEc.ToString();
            //this.cLOSEc = quClone.CLOSEc;

        }
        public QuoteBase(DateTime dt, double close)
        {
            this.date = dt;
            this.cLOSEc = close;

        }

		
		#endregion

		#region Interface IQuote - Properties
		
	
		public double CLOSEc 
		{
			get
			{
				return this.cLOSEc;
			}
			set
			{
				this.cLOSEc = value;
			}
		}
		
	
		
		public DateTime DATE 
		{
			get
			{
				return this.date;
			}
			set
			{
				this.date = value;
			}
		}
        public DateTime TIME_OfDay
        {
            get
            {
                return this.time_OfDay;
            }
            set
            {
                this.time_OfDay = value;
            }
        }
		
	
		#endregion

        #region general

   
        public object Clone()
        {
            //Share is lowest common Element
            return this.MemberwiseClone() as IQuoteBase;
        }
        public int CompareTo(object obj)
        {
            return this.DATE.Ticks.CompareTo(((IQuoteBase)obj).DATE.Ticks);
        }

        public override int GetHashCode()
        {
            string locQuoteString = "QuoteBase" + this.date.ToString();
            return locQuoteString.GetHashCode();
        }
        public override bool Equals(object newObject)
        {
            try
            {
                if (base.Equals(newObject))
                {
                    return true;
                }
                QuoteBase newQuote = (QuoteBase)newObject;
                return (this.GetHashCode() == newQuote.GetHashCode());
            }
            catch
            {
            }
            return false;
        }

        #endregion

    }
}
